<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
require_once __DIR__ . "/Common.php";
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if(is_null($ossClient)) {
    exit(1);
}
$refererConfig = new OSS\Model\RefererConfig();
$refererConfig->setAllowEmptyReferer(true);
$refererConfig->addReferer("www.aliiyun.com");
$refererConfig->addReferer("www.aliiyuncs.com");
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket " . $bucket . " refererConfig created:" . $refererConfig->serializeToXml());
$refererConfig = $ossClient->getBucketReferer($bucket);
Common::println("bucket " . $bucket . " refererConfig fetched:" . $refererConfig->serializeToXml());
$refererConfig = new OSS\Model\RefererConfig();
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket " . $bucket . " refererConfig deleted");
putBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
deleteBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
function putBucketReferer($ossClient, $bucket)
{
    $refererConfig = new OSS\Model\RefererConfig();
    $refererConfig->setAllowEmptyReferer(true);
    $refererConfig->addReferer("www.aliiyun.com");
    $refererConfig->addReferer("www.aliiyuncs.com");
    try {
        $ossClient->putBucketReferer($bucket, $refererConfig);
    } catch (OSS\Core\OssException $e) {
        printf("putBucketReferer: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "putBucketReferer: OK\n";
}
function getBucketReferer($ossClient, $bucket)
{
    $refererConfig = NULL;
    try {
        $refererConfig = $ossClient->getBucketReferer($bucket);
    } catch (OSS\Core\OssException $e) {
        printf("getBucketReferer: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "getBucketReferer: OK\n";
    echo $refererConfig->serializeToXml() . "\n";
}
function deleteBucketReferer($ossClient, $bucket)
{
    $refererConfig = new OSS\Model\RefererConfig();
    try {
        $ossClient->putBucketReferer($bucket, $refererConfig);
    } catch (OSS\Core\OssException $e) {
        printf("deleteBucketReferer: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "deleteBucketReferer: OK\n";
}

?>